package cqie.personal.frame.controller;


import cqie.personal.frame.bo.GetCharacterBO;
import cqie.personal.frame.config.RequiredPermission;
import cqie.personal.frame.enums.Code;
import cqie.personal.frame.exception.ValidationFailException;
import cqie.personal.frame.service.CharacterInfoService;
import cqie.personal.frame.service.impl.CharacterServiceImpl;
import cqie.personal.frame.vo.CharacterView;
import cqie.personal.frame.vo.PageVO;
import cqie.personal.frame.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Yeeeeee
 * @since 2021-09-08
 */

@Api(tags = "角色相关公共接口模块")
@RestController
@RequestMapping("/character-info")
@RequiredPermission(0)
public class CharacterInfoController {
    @Resource
    private CharacterServiceImpl characterServiceImpl;

    @ApiOperation("条件查询角色")
    @GetMapping("/getCharacter")
    public ResultVO getCharacter(GetCharacterBO getCharacterBO) throws ValidationFailException {
        PageVO<List<CharacterView>> result = characterServiceImpl.getCharacter(getCharacterBO);
        if(result != null){
            if(result.getRecordCount()>0){
                return new ResultVO(result);
            }
            return new ResultVO(Code.NULL_DATA.getCode(),Code.NULL_DATA.getMessage());
        }
        return new ResultVO(Code.OPERATION_FAIL.getCode(),Code.OPERATION_FAIL.getMessage());
    }

}

